////////////////////////////////////////////////////////////////////////////
//
//  Crytek Engine Source File.
//  Copyright (C), Crytek Studios, 2008.
// -------------------------------------------------------------------------
//  File name:   AIEnvironment.cpp
//  Created:     29/02/2008 by Matthew
//  Description: Simple global struct for accessing major module pointers
// -------------------------------------------------------------------------
//  History:
//
////////////////////////////////////////////////////////////////////////////

#include "StdAfx.h"
#include "Environment.h"



#include "ObjectContainer.h"

#include "CodeCoverageManager.h"
#include "CodeCoverageGUI.h"
#include "GoalOpFactory.h"
#include "StatsManager.h"
#include "TacticalPointSystem/TacticalPointSystem.h"
#include "TargetSelection/TargetTrackManager.h"
#include "Walkability/WalkabilityCacheManager.h"
#include "NullAIDebugRenderer.h"
#include "Navigation/NavigationSystem/NavigationSystem.h"


static CNullAIDebugRenderer nullAIDebugRenderer;


SAIEnvironment::SAIEnvironment()
: pActorLookUp(NULL)
, pGoalOpFactory(NULL)
, pObjectContainer(NULL)
, pCodeCoverageTracker(NULL)
, pCodeCoverageManager(NULL)
, pCodeCoverageGUI(NULL)
, pTacticalPointSystem(NULL)
, pTargetTrackManager(NULL)
, pStatsManager(NULL)
, pPipeManager(NULL)
, pAIActionManager(NULL)
, pSmartObjectManager(NULL)
, pPerceptionManager(NULL)
, pCoordinationManager(NULL)
, pCommunicationManager(NULL)
, pNavigationSystem(NULL)
, pSelectionTreeManager(NULL)
, pVisionMap(NULL)
, pFactionMap(NULL)
, pGroupManager(NULL)
, pCollisionAvoidanceSystem(NULL)
, pRayCaster(NULL)
, pIntersectionTester(NULL)
{
	SetDebugRenderer(NULL);

#ifdef CRYAISYSTEM_DEBUG
	pRecorder = NULL;
#endif //CRYAISYSTEM_DEBUG
}

SAIEnvironment::~SAIEnvironment()
{
}

void SAIEnvironment::ShutDown()
{
	SAFE_DELETE(pActorLookUp);
	SAFE_DELETE(pFactionMap);
	SAFE_DELETE(pWalkabilityCacheManager);
	SAFE_DELETE(pGoalOpFactory);
	SAFE_DELETE(pCodeCoverageTracker);
	SAFE_DELETE(pCodeCoverageManager);
	SAFE_DELETE(pCodeCoverageGUI);
	SAFE_DELETE(pStatsManager);
	SAFE_DELETE(pTacticalPointSystem);
	SAFE_DELETE(pTargetTrackManager);
	SAFE_DELETE(pObjectContainer);
}

void SAIEnvironment::SetDebugRenderer(IAIDebugRenderer* pAIDebugRenderer)
{
	this->pAIDebugRenderer = pAIDebugRenderer ? pAIDebugRenderer : &nullAIDebugRenderer;
}

#ifdef CRYAISYSTEM_DEBUG

CAIRecorder* SAIEnvironment::GetAIRecorder()
{
	return pRecorder;
}

void SAIEnvironment::SetAIRecorder(CAIRecorder *pAIRecorder)
{
	pRecorder = pAIRecorder;
}

#endif //CRYAISYSTEM_DEBUG


SAIEnvironment gAIEnv;
